package com.touzhijia.scheduler.controller;

import com.touzhijia.common.controller.BaseController;
import com.touzhijia.common.persistence.Page;
import com.touzhijia.scheduler.service.SchedulerLogService;
import com.touzhijia.scheduler.vo.request.QrtzSchedulerLogQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 作者：lizw <br/>
 * 创建时间：2017/6/2 10:48 <br/>
 */
@Controller
@RequestMapping(value = "/quartz/schedulerLog")
public class SchedulerLogController extends BaseController {

    @Autowired
    private SchedulerLogService schedulerLogService;

//    @RequestMapping("/SchedulerLog" + VIEW_PAGE_SUFFIX)
//    public ModelAndView getSchedulerLogJsp(HttpServletRequest request, HttpServletResponse response) {
//        return new ModelAndView(QuartzJspUrlPath.SchedulerLog);
//    }

    @RequestMapping("/findSchedulerLogByPage")
    @ResponseBody
    public Object findSchedulerLogByPage(
            HttpServletRequest request,
            HttpServletResponse response,
            @Valid QrtzSchedulerLogQuery qrtzSchedulerLogQuery,
            BindingResult bindingResult) {

        return schedulerLogService.findByPage(
                new Page<>(request, response),
                qrtzSchedulerLogQuery.getSchedulerName(),
                qrtzSchedulerLogQuery.getInstanceName(),
                qrtzSchedulerLogQuery.getMethodName(),
                qrtzSchedulerLogQuery.getLogTimeStart(),
                qrtzSchedulerLogQuery.getLogTimeEnd());
    }
}
